import $ from 'jquery';
import Button from './Button';

export default class UnderlineButton extends Button {
    render() {
        if (this.editor.util.os.mac) {
            this.title = `${this.title} ( Cmd + u )`;
        } else {
            this.title = `${this.title} ( Ctrl + u )`;
            this.shortcut = 'ctrl+u';
        }
        return super.render.call(this);
    }
    _activeStatus() {
        let active = document.queryCommandState('underline') === true;
        this.setActive(active);
        return this.active;
    }
    command() {
        document.execCommand('underline');
        if (!this.editor.util.support.oninput) {
            this.editor.trigger('valuechanged');
        }
        return $(document).trigger('selectionchange');
    }
}
UnderlineButton.prototype.name = 'underline';
UnderlineButton.prototype.icon = 'underline';
UnderlineButton.prototype.htmlTag = 'u';
UnderlineButton.prototype.disableTag = 'pre';
UnderlineButton.prototype.shortcut = 'cmd+u';